//
//  YRJDestinationCollectionReusableView.m
//  YanRenjie
//
//  Created by dllo on 15/10/23.
//  Copyright (c) 2015年 yanrenjie. All rights reserved.
//

/*
    目的地页面上的collectionView的头部上面放的一个地图, 以及地图上的7个洲按钮和7个洲按钮下面的小点
 */

#import "YRJDestinationCollectionReusableView.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height
@implementation YRJDestinationCollectionReusableView

- (void)dealloc {
    [_mapImageView release];
    
    [_AsiaButton release];
    [_AsiaLabel release];
    [_EuropeButton release];
    [_EuropeLabel release];
    [_SouthAmericaButton release];
    [_SouthAmericaLabel release];
    [_NorthAmericaButton release];
    [_NorthAmericaLabel release];
    [_AfricaButton release];
    [_AfricaLabel release];
    [_OceaniaButton release];
    [_OceaniaLabel release];
    [_AntarcticaButton release];
    [_AntarcticaLabel release];
    
    [_titleNameLabel release];
    
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.mapImageView = [[UIImageView alloc] init];
        [self addSubview:self.mapImageView];
        [_mapImageView release];
        
        self.titleNameLabel = [[UILabel alloc] init];
        [self addSubview:self.titleNameLabel];
        [_titleNameLabel release];
        self.titleNameLabel.backgroundColor = [UIColor whiteColor];
        
        self.AsiaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.AsiaButton];
        [self.AsiaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.AsiaButton.backgroundColor = [UIColor clearColor];
        self.AsiaLabel = [[UILabel alloc] init];
        self.AsiaLabel.backgroundColor = [UIColor blackColor];
        self.AsiaLabel.layer.masksToBounds = YES;
        [self.mapImageView addSubview:self.AsiaLabel];
        [_AsiaLabel release];
        
        self.EuropeButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.EuropeButton];
        [self.EuropeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.EuropeButton.backgroundColor = [UIColor clearColor];
        self.EuropeLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.EuropeLabel];
        self.EuropeLabel.backgroundColor = [UIColor blackColor];
        self.EuropeLabel.layer.masksToBounds = YES;
        [_EuropeLabel release];
        
        self.NorthAmericaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.NorthAmericaButton];
        [self.NorthAmericaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.NorthAmericaButton.backgroundColor = [UIColor clearColor];
        self.NorthAmericaLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.NorthAmericaLabel];
        self.NorthAmericaLabel.backgroundColor = [UIColor blackColor];
        self.NorthAmericaLabel.layer.masksToBounds = YES;
        [_NorthAmericaLabel release];
        
        self.SouthAmericaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.SouthAmericaButton];
        [self.SouthAmericaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.SouthAmericaButton.backgroundColor = [UIColor clearColor];
        self.SouthAmericaLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.SouthAmericaLabel];
        self.SouthAmericaLabel.backgroundColor = [UIColor blackColor];
        self.SouthAmericaLabel.layer.masksToBounds = YES;
        [_SouthAmericaLabel release];
        
        self.AfricaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.AfricaButton];
        [self.AfricaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.AfricaButton.backgroundColor = [UIColor clearColor];
        self.AfricaLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.AfricaLabel];
        self.AfricaLabel.backgroundColor = [UIColor blackColor];
        self.AfricaLabel.layer.masksToBounds = YES;
        [_AfricaLabel release];
        
        self.OceaniaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.OceaniaButton];
        [self.OceaniaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.OceaniaButton.backgroundColor = [UIColor clearColor];
        self.OceaniaLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.OceaniaLabel];
        self.OceaniaLabel.backgroundColor = [UIColor blackColor];
        self.OceaniaLabel.layer.masksToBounds = YES;
        [_OceaniaLabel release];
        
        self.AntarcticaButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.mapImageView addSubview:self.AntarcticaButton];
        [self.AntarcticaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.AntarcticaButton.backgroundColor = [UIColor clearColor];
        self.AntarcticaLabel = [[UILabel alloc] init];
        [self.mapImageView addSubview:self.AntarcticaLabel];
        self.AntarcticaLabel.backgroundColor = [UIColor blackColor];
        [_AntarcticaLabel release];
        self.AntarcticaLabel.layer.masksToBounds = YES;
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.mapImageView.frame = CGRectMake(0, 0, WIDTH, (200.0 / 240) * HEIGHT);
    self.titleNameLabel.frame = CGRectMake((20.0 / 375.0) * WIDTH, (200.0 / 240.0) * HEIGHT, (335.0 / 375.0) * WIDTH, (40.0 / 240.0) * HEIGHT);
    
    self.AsiaButton.frame = CGRectMake((250.0 / 375.0) * WIDTH, (30.0 / 240.0) * HEIGHT, (50.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.AsiaLabel.frame = CGRectMake((275 / 375.0) * WIDTH, (55.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.AsiaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.EuropeButton.frame = CGRectMake((150.0 / 375.0) * WIDTH, (10.0 / 240.0) * HEIGHT, (50.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.EuropeLabel.frame = CGRectMake((175.0 / 375.0) * WIDTH, (35.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.EuropeLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.NorthAmericaButton.frame = CGRectMake((50.0 / 375.0) * WIDTH, (15.0 / 240.0) * HEIGHT, (60.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.NorthAmericaLabel.frame = CGRectMake((75.0 / 375.0) * WIDTH, (40.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.NorthAmericaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.SouthAmericaButton.frame = CGRectMake((80.0 / 375.0) * WIDTH, (120.0 / 240.0) * HEIGHT, (60.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.SouthAmericaLabel.frame = CGRectMake((105.0 / 375.0) * WIDTH, (110.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.SouthAmericaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.AfricaButton.frame = CGRectMake((170.0 / 375.0) * WIDTH, (80.0 / 240.0) * HEIGHT, (50.0 / 375.0) * WIDTH, (20.0 / 240) * HEIGHT);
    self.AfricaLabel.frame = CGRectMake((195.0 / 375.0) * WIDTH, (105.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.AfricaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.OceaniaButton.frame = CGRectMake((300.0 / 375.0) * WIDTH, (145.0 / 240.0) * HEIGHT, (60.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.OceaniaLabel.frame = CGRectMake((325.0 / 375.0) * WIDTH, (135.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.OceaniaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    self.AntarcticaButton.frame = CGRectMake((200.0 / 375.0) * WIDTH, (165.0 / 240.0) * HEIGHT, (60.0 / 375.0) * WIDTH, (20.0 / 240.0) * HEIGHT);
    self.AntarcticaLabel.frame = CGRectMake((220.0 / 375.0) * WIDTH, (190.0 / 240.0) * HEIGHT, (5.0 / 375.0) * WIDTH, (5.0 / 375.0) * WIDTH);
    self.AntarcticaLabel.layer.cornerRadius = (5.0 / 375.0) * WIDTH / 2;
    
    NSLog(@"%f", self.frame.size.width);
    NSLog(@"%f", self.frame.size.height);
}
@end
